﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Payroll;
using System.Data.SqlServerCe;
using System.Data.SqlClient;

namespace Payroll
{
    public partial class Hourlyemployee : System.Windows.Forms.Form
    {
        public Hourlyemployee()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int id = int.Parse(textid.Text);
            string name = textname.Text;
            string address = textaddress.Text;
            float rate = float.Parse(textrate.Text);
            PayrollDatabase pd = new sytpayrolldatabase();
            AddHourlyEmployee emp = new AddHourlyEmployee(id, name, address, rate, pd);
            emp.Execute();

            myFile.myWrite_operate(myUser.Name, "新增钟点工 id: " + id + "  姓名: " + name);

        }

        private void Hourlyemployee_Load(object sender, EventArgs e)
        {
            string sqlStr;
            int i = 0;
            string connString = @"Data Source=..\..\Database1.sdf";
            SqlCeConnection connection = new SqlCeConnection(connString);
            connection.Open();
            sqlStr = " select id from Summarytable order by id";
            SqlCeCommand cmd = new SqlCeCommand(sqlStr, connection);
            SqlCeDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                i = Convert.ToInt32(reader[0]) + 1;
                Console.WriteLine(i);
            }
            connection.Close();
            textid.Text = Convert.ToString(i);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void textid_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
